Skip to content

DEV-1110: read the BMP581 in-band sensor ID and add SR38-4-2 to the SR rule - #311

Merged
MAzalya merged 1 commit into
masterfrom
DEV-1110_bmp581_inband_sensor_id
Oct 2, 2026
Merged

MAzalya merged 1 commit into
masterfrom
DEV-1110_bmp581_inband_sensor_id

Conversation

@marknolan

Copy link
Copy Markdown
Member

Jira: DEV-1110. This is a follow-up to DEV-852 and is independent of #310 (DEV-1102): it touches none of #310's lines, and git merge-tree against it is clean. Part of the BMP581 host rollout, with Shimmer-C-API#208, SwiftAPI#20, shimmer-web-sdk#168 and the pyshimmer upstream PR.

Problem

  • The driver decided BMP581 vs BMP390 from the SR number and firmware version alone, and never sent 0xA7 to a BMP581 candidate.
    • LogAndStream_Shimmer3R v1.01.007+ answers 0xA7 with [A6][01][03] (sensor ID 3), see shimmer_bt_uart.c:2064-2099.
    • The firmware picks the chip by chip ID first (hal_pressure.c), so a board whose fitted chip disagrees with its SR number was decoded wrongly.
  • The SR rule omitted SR38 (Proto3 Deluxe) >= 4.2, which the firmware's ShimBrd_isBmp581PresentPerSrNumber() includes.
  • The 0xA6 handler read a fixed length based on the sensor it assumed.

Change

  • 0xA6 handler. It reads the device's length byte, then [sensorId][coefficients], and validates the count against the ID (22/24/21/0). A mismatch is logged and rejected, and the stream stays in step.
    • On a Shimmer3R, ID 2 or 3 is recorded by setPressureSensorIdInBand(), which overrides the SR rule in either direction.
    • If the sensor class in use is wrong, the sensor maps are rebuilt and the config bytes re-parsed, so settings such as oversampling survive.
    • The BMP390 coefficients (ID 2) go through the same bytes and code as before.
  • Sending 0xA7. It is sent on every Shimmer3R except a BMP581 candidate on exactly v1.01.006. Master has no NACK handling (DEV-982), and v1.01.006 NACKs, which costs the connection. The skip can go once DEV-982 lands.
  • SR rule. SR38 >= 4.2 is added, and the SR48 rev-7 band is written in the firmware's form. The static isSupportedBmp581(svo, ebd) is still the SR rule on its own, used for SD logs, whose header carries no sensor ID.
  • In-band ID reset. The ID is cleared whenever the expansion board details change.
  • SensorBMP581. The comment that the firmware NACKs 0xA7 is corrected.

Tests

  • API_00020_Bmp581SrRuleTest (ShimmerDriver):
    • every firmware test_bmp581_gate case, including SR48-8.0/8.1 = BMP390 and SR38-4-2 = BMP581;
    • a Shimmer3 host, unprogrammed cards, the firmware guard, and the coefficient lengths.
  • API_00021_Bmp581InBandSensorIdTest (ShimmerDriverPC). It drives the real handler from a byte queue and covers:
    • ID 3 on a BMP390 board, and ID 2 on a BMP581 board (sensor switch plus coefficients);
    • rejected lengths and IDs;
    • clearing on a new board;
    • oversampling 7 surviving the switch;
    • the 0xA7 decision for 1.1.5, 1.1.6, 1.1.7 and 1.2.0.
  • Neither test is added to the API_00005 suite, as with DEV-1102.
  • ShimmerDriver ./gradlew test: 113 tests, 0 failures.
  • ShimmerDriverPC ./gradlew build: 142 tests, 0 failures, including the existing Shimmer3R connect test.

Not verified / known

  • No bench run on v1.01.007+ BMP581, BMP390, or v1.01.006.
  • ByteCommunicationSimulatorS3R answers 0xA7 with a Shimmer3 BMP280 payload. That is now rejected on a 3R, where master used to apply it as BMP390 coefficients. The simulator is unchanged.
  • With setUseInfoMemConfigMethod(false), ranges read individually before 0xA7 are not re-applied after a sensor switch.

After merge: bump ASM_PC's submodule pin, along with #310.

🤖 Generated with Claude Code

The 0xA6 PRESSURE_CALIBRATION_COEFFICIENTS_RESPONSE is
[0xA6][len = 1+n][sensorId][n coefficient bytes], but the driver read a
fixed length chosen from the sensor it had assumed. It now reads the
length byte, then the payload, validates the length against the sensor
ID (BMP180 22, BMP280 24, BMP390 21, BMP581 0) and rejects a mismatch
instead of applying it. The stream stays in step either way.

On a Shimmer3R the sensor ID overrides the SR-number rule in both
directions: ShimmerObject.mPressureSensorIdInBand is consulted first by
isSupportedBmp581(), and if the sensor class in use is the wrong one the
sensor classes are rebuilt and the config bytes re-parsed into the new
class. The ID is cleared when the expansion board details change. The
BMP390 path passes the same 21 coefficient bytes as before.

0xA7 is now sent to Shimmer3R boards the SR rule marks as BMP581 when the
firmware is v1.01.007+, which answers [A6][01][03]. It is still skipped
on v1.01.006, which NACKs it on a BMP581: master has no NACK handling
(DEV-982 is unmerged), so an unanswered command times out and drops the
connection, and the SR-rule result stands there.

The SR rule gains SR38 (Proto3 Deluxe) >= 4.2 and is now written as the
firmware's ShimBrd_isBmp581PresentPerSrNumber(). API_00020 copies the
firmware's test_bmp581_gate() cases; API_00021 (ShimmerDriverPC, as it
needs ShimmerPC) covers 0xA6 parsing, the override and the 0xA7 decision.
Neither is added to the API_00005 suite, as with DEV-1102.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@MAzalya MAzalya left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok tested, looks good

@MAzalya
MAzalya merged commit a6ca85c into master Oct 2, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants